#include <QtGui>
#include <QTranslator>
#include <QtCore/QTextCodec>
#include "gv_systemselectiondialog.h"
#include "gv_systemcomconfigurationdialog.h"
#include "gv_systemhomedialog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_SystemSelectionDialog::GV_SystemSelectionDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(AcceptButton,SIGNAL(clicked()),this,SLOT(accept()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(cancel()));
    connect(COMConfigurationButton,SIGNAL(clicked()),this,SLOT(COMConfiguration()));
    connect(SystemselectionButton,SIGNAL(currentChanged()),this,SLOT(SystemSelection()));

    connect(IndividualRadio,SIGNAL(clicked()),this,SLOT(checkInvididual()));
    connect(CabinetRadio,SIGNAL(clicked()),this,SLOT(checkCabinet()));
    timer->start(1000);
}
void GV_SystemSelectionDialog::reloadtext()
{
    //NameHintsLabel->setText(tr("Zones"));
}
void GV_SystemSelectionDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_SystemSelectionDialog::accept()
{
    QDialog *dialog1 = new GV_SystemHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}
void GV_SystemSelectionDialog::cancel()
{
    QDialog *dialog1 = new GV_SystemHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_SystemSelectionDialog::COMConfiguration()
{
    QDialog *dialog1 = new GV_SystemCOMConfigurationDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_SystemSelectionDialog::SystemSelection()
{

}

void GV_SystemSelectionDialog::checkInvididual()
{
    invididualEnabled = true;
}
void GV_SystemSelectionDialog::checkCabinet()
{
    invididualEnabled = false;
}
